#include "tuya_cloud_types.h"

#include "tal_api.h"
#include "tkl_output.h"
#include "tkl_timer.h"

static long long time_ms; 

#define TIME_PERIOD_US 50 * 1000 // us


int get_time_ms(void) 
{
	long long tmp_time_ms;

	tmp_time_ms = time_ms;

	do {
		
	} while(tmp_time_ms != time_ms)
}

static void _time_callback(void *args)
{
    time_ms++;

    return;
}

void time_init(void)
{

	/* timer init */
	TUYA_TIMER_BASE_CFG_T sg_timer_cfg = {.mode = TUYA_TIMER_MODE_PERIOD, .args = NULL, .cb = _time_callback};
	TUYA_CALL_ERR_GOTO(tkl_timer_init(TUYA_TIMER_NUM_0, &sg_timer_cfg), __EXIT);

	/*start timer*/
	TUYA_CALL_ERR_GOTO(tkl_timer_start(TUYA_TIMER_NUM_0, TIME_PERIOD_US), __EXIT);
	
__EXIT:
	return;
}
